<?php
/**
 * Created by Command.
 * User: Vito
 */

namespace app\admin\curd\system_auth;

use app\common\curd\Index;
use app\admin\curd\system_role\SystemRoleTrait;

class SystemAuthIndex extends Index
{
    use SystemRoleTrait;

    /**
     * 关键词查询指定字段
     * @var string[]
     */
    protected $keywordQueryArgs = ['index'];
    //追加数据
    protected $appendCallback = [];
    protected $labelCallback = [
        'get_status_enum' => ['name' => '状态', 'key' => 'status'],
        'get_module_enum' => ['name' => '模块', 'key' => 'module'],
    ];
    //查询条件
    protected $where = [];
    //字段
    protected $field = [];
    //排除字段
    protected $withoutField = false;

    protected $usePaginate = false;

    protected $limit = 0;

    protected $format = 'tree';

    protected $queryField = ['module', 'status', 'is_menu', 'pid'];

    protected function init($next)
    {
        $ids = $this->getHasAuthId();

        //获取自身有的权限
        if (is_array($ids)) {
            $this->where[] = ['id', 'IN', $ids,];
        }

        return parent::init($next); // TODO: Change the autogenerated stub
    }
}
